﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>Admin UI</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META http-equiv=expires content=0>
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Cache-Control content=no-cache>
<link href="<?=$TPL[url]?>css/admin_index.css" rel="stylesheet" type="text/css">
<?if(0){?>
<link href="css/admin_index.css" rel="stylesheet" type="text/css">
<?}?>
</HEAD>
<BODY onkeydown="keyCodes('menu',event);" scroll=no>
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD vAlign=top colSpan=2 height=80><DIV id=header>
          <DIV class="logo fl">
            <DIV class=png><IMG 
      src="<?=$TPL[url]?>images/logo.png"></DIV>
            <DIV class=lun><A 
      href="<?=URL_WEB?>" 
      target=_blank> 查看网站首页</A></DIV>
          </DIV>
          <!--重点导航-->
          <UL class=nav>
		  	<?$i=0;foreach ($nav as $cid => $name) {?>
            <LI id=<?=$cid?> <?if(0==$i){print("class='home'");$i=1;}?> onmouseover=showguide(this.id);><A 
        style="CURSOR: pointer" onClick="return initguide('<?=$cid?>');" 
        href="#"><?=$name?></A>
            </LI>
			<? }?>
            <LI class=more><A onClick="return showmenu();" 
        href="#">菜单</A> </LI>
          </UL>
          <!--头部信息导航-->
          <DIV id=guide></DIV>
          <!--头部信息导航结束-->
        </DIV></TD>
    </TR>
    <TR>
      <TD id=main-fl vAlign=top><DIV id=left></DIV>
        <DIV></DIV></TD>
      <TD id=mainright vAlign=top><!--右边开始-->
        <IFRAME style="OVERFLOW: visible" 
      name=main src="admin.htm" frameBorder=0 width="100%" 
      scrolling=yes height="100%"></IFRAME></TD>
    </TR>
  </TBODY>
</TABLE>
<IFRAME 
style="WIDTH: 0px; HEIGHT: 0px" name=notice src="about:blank" 
frameBorder=0></IFRAME>
<DIV id=menu style="DISPLAY: none"></DIV>
<DIV id=showmenu style="DISPLAY: none"></DIV>
<SCRIPT language=JavaScript>
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf('msie')!=-1) && (agt.indexOf('opera')==-1));
var is_gecko= (navigator.product == "Gecko");
var is_ns = (document.layers);
var is_w3 = (document.getElementById && !is_ie);
var sch = 0;
var guides = <?=$json_guides?>;
var titles = <?=$json_titles?>;
var cate   = 'c_1';
var action = '';
var type   = '';

document.getElementById('mainright');
function showguide(id){
	var obj = document.getElementById('showmenu');
	var guide = guides[id];
	var html  = '<dl>';
	for(i in guide){
		var subs = guide[i];
		html += '<dd>';
		for(j in subs){
			var sub = subs[j];
			html += '<a href="#" onclick="return initguide(\''+id+'\',\''+j+'\')">'+sub[0]+'</a>';
		}
		html += '</dd>';
	}
	obj.innerHTML = html + '</dl>';
	var obj1  = document.getElementById(id);
	var left  = findPosX(obj1) + getLeft();
	var top   = findPosY(obj1) + getTop() + 22;
	obj.style.display = "";
	obj.style.top	= top + 'px';
	obj.style.left	= left + 'px';
	addEvent(document,"mouseout",doc_mouseout);
}
function closeguide(){
	var obj = document.getElementById('showmenu');
	obj.style.display = "none";
	removeEvent(document,"mouseout",doc_mouseout);
}
function upleft(t){
	var obj  = document.getElementById('left');
	var objli = obj.getElementsByTagName('li');
	var obja = obj.getElementsByTagName('a');
	for(var i=0;i<obja.length;i++){
		objli[i].className = obja[i].id==t ? 'one' : '';
	}
}
function showleft(id,t,url){
	cate = id;
	var obj = document.getElementById('left');
	
	var html = '';
	var guide = guides[id];
	url = typeof url != 'undefined' ? url : '';
	type = typeof t != 'undefined' ? t : '';

	for(i in guide){
		var subs = guide[i];
		html += '<h1>' + titles[i] + '</h1><div class="cc"></div><ul>';
		for(j in subs){
			var sub = subs[j];
			html += '<li><a id="'+j+'" href="#" onclick="return initguide(\''+id +'\',\''+j+'\')">'+sub[0]+'</a></li>';
			if(url==''){
				if(type == ''){
					url = sub[1];
					type = j;
				} else if(j == type){
					url = sub[1];
				}
				action = i;
			}
		}
		html += '</ul>';
		if (i=='diy') {
			html += '<h2 style="cursor:pointer" onclick="return initguide(\'initiator\',\'diyoption\')">常用功能定制</h2>';
		}
	}
	obj.innerHTML = html;
	upleft(type);
	if (is_ie && sch>0) sch = 0;
	parent.main.location = url;
	return false;
}
function showtitle(){
	var obj = document.getElementById('guide');
	var guide = guides[cate];
	var html = '';
	if (cate && action && type) {
		if (cate=='common') {
			html += '<div class="wei fl"><a href="<?=_url('AdminIndex')?>">首页</a> &raquo; <a href="#" onclick="return initguide(cate,type,"")">'+titles[action]+'</a> &raquo; <a href="#">'+guide[action][type][0]+'</a></div>';
		} else {
			html += '<div class="wei fl"><a href="<?=_url('AdminIndex')?>">首页</a> &raquo; <a href="#" onclick="return initguide(\''+cate+'\')">'+titles[action]+'</a> &raquo; <a href="#" onclick="return initguide(\''+cate+'\',\''+type+'\')">'+guide[action][type][0]+'</a></div>';
		}
	}
	html += '<ul class="fr"><li class="home">用户名：<?=$user['username']?></li><li>级别：<?=$user['_group']?></li><li><a class="s0" style="cursor:pointer" onclick="parent.main.location.reload();" title="刷新主页面">刷新</a></li><li><a class="s0" style="cursor:pointer" onclick="parent.main.history.go(-1);" title="后退到前一页">后退</a></li><li><a href="<?=_url('AdminLogin','Out')?>">注销</a></li></ul>';
	if (is_ie || is_ns || is_w3 && agt.indexOf('opera')==-1) {
		html += '<div class="value fr"><input type="text" class="input" id="schstring" onfocus="document.getElementById(\'schbt\').disabled = false;" onclick="this.select();" />&nbsp;<input class="btn" type="button" id="schbt" value="查找下一个" onclick="PwFindInPage();" /></div>';
	}
	obj.innerHTML = html;
}
function initguide(id,t,url){
	showleft(id,t,url);
	showtitle();
	return false;
}
function showmenu(){
	var obj = document.getElementById('menu');
	top.main.showselect('hidden');
	if(!IsElement('menubg')){
		var html = '<div><div><a style="cursor:pointer;" onclick="closemenu();" class="fr"><img src="<?=$TPL['url']?>images/close.gif" /></a><h1>按"ESC"键关闭或开启此菜单</h1>';
		for(i in guides){
			if(i=='common') continue;
			var guide = guides[i];
			html += "<dl>";
			for(j in guide){
				html += "<dt><h3>" + titles[j] + "</h3></dt><dd>";
				var subs = guide[j];
				for(k in subs){
					var sub = subs[k];
					html += '<a href="#" onclick="return toguide(\''+i+'\',\''+k+'\')">'+sub[0]+'</a>';
				}
				html += "</dd>";
			}
			html += '</dl>';
		}
		html += '<div class="c"></div></div></div>';
		obj.innerHTML = html;
		var obj2 = document.createElement("div");
		obj2.id = "menubg";
		obj.parentNode.insertBefore(obj2,obj);
	} else {
		var obj2 = document.getElementById('menubg');
		obj2.style.display = "";
	}
	obj.style.display = "";
	addEvent(document,"mousedown",doc_mousedown);
}
function closemenu(){
	var obj = document.getElementById('menu');
	obj.style.display = "none";
	var obj2 = document.getElementById('menubg');
	obj2.style.display = "none";
	removeEvent(document,"mousedown",doc_mousedown);
	top.main.showselect('');
}
function toguide(id,t){
	closemenu();
	initguide(id,t);
	return false;
}
function doc_mousedown(e){
	var e = is_ie ? event: e;
	obj	= document.getElementById("menu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + getTop() : e.pageY;
	_x1 = obj.offsetLeft;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = obj.offsetTop - 20;
	_y2 = obj.offsetTop + obj.offsetHeight;

	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
	   closemenu();
	}
}
function doc_mouseout(e){
	var e = is_ie ? event: e;
	obj	= document.getElementById("showmenu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + getTop() : e.pageY;
	_x1 = obj.offsetLeft + 2;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = obj.offsetTop - 20;
	_y2 = obj.offsetTop + obj.offsetHeight;

	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
		closeguide();
	}
}
function IsElement(id){
	return document.getElementById(id)!=null ? true : false;
}
function addEvent(el,evname,func){
	if(is_ie){
		el.attachEvent("on" + evname,func);
	} else{
		el.addEventListener(evname,func,true);
	}
};
function removeEvent(el,evname,func){
	if(is_ie){
		el.detachEvent("on" + evname,func);
	} else{
		el.removeEventListener(evname,func,true);
	}
};
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft - getLeft();
}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y){
		curtop += obj.y;
	}
	return curtop - getTop();
}
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function getTop() {
	return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:ietruebody().scrollTop;
}
function getLeft() {
	return (typeof window.pageXOffset != 'undefined' ? window.pageXOffset:ietruebody().scrollLeft)
}
function keyCodes(id,e){
	if (e.keyCode==27) {
		if (IsElement(id) && document.getElementById(id).style.display=='') {
			closemenu();
		} else {
			try{
				showmenu();
			} catch(e){}
		}
	} else if (is_ie && (e.keyCode==116 || (e.ctrlKey && e.keyCode==82))) {
		e.keyCode = 0;
		e.returnValue = false;
		parent.main.location.reload();
	}
	return false;
}
function PwFindInPage(){
	if (document.getElementById('schstring').value!='') {
		FindInPage(document.getElementById('schstring').value);
		document.getElementById('schbt').disabled = false;
	} else {
		document.getElementById('schbt').disabled = true;
	}
}
function FindInPage(str){
	if (!str) {
		alert('未找到指定内容');
		return false;
	}
	if (is_w3 || is_ns) {
		if (!parent.main.find(str)) {
			alert('到达页尾，从页首继续');
			while (1) {
				if (!parent.main.find(str,false,true)) break;
			}
			return false;
		}
	} else if (is_ie) {
		var found;
		var txt = parent.main.document.body.createTextRange();
		for (var i = 0; i <= sch && (found = txt.findText(str)) != false; i++) {
			txt.moveStart('character',1);
			txt.moveEnd('textedit');
		}
		if (found) {
			sch++;
			txt.moveStart('character',-1);
			txt.findText(str);
			try {
				txt.select();
				txt.scrollIntoView();
			} catch(e) {FindInPage(str);}
		} else {
			if (sch > 0) {
				sch = 0;
				alert('到达页尾，从页首继续');
				FindInPage(str);
			} else {
				alert('未找到指定内容');
			}
			return false;
		}
	}
	return true;
}
function getPageHeight(){
	if (self.innerHeight) {
		return self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} else if (document.body) {
		return document.body.clientHeight;
	}
}
initguide(cate,type,"");
</SCRIPT>
<!---->
</BODY>
</HTML>
